<%@page import="java.io.PrintWriter"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="java.io.*"%>
<%@page import="cn.iutils.code.entity.*"%>
<jsp:useBean id="UI" class="cn.iutils.code.main.Ajax" scope="page" />
<%
	String action = request.getParameter("action");
	switch (action) {
	case "gettable":
		String dbName = request.getParameter("db");
		List<TableModel> tabs = UI.getTables(dbName);
		PrintWriter pw = response.getWriter();
		pw.write("[");
		for (int idx = 0; idx < tabs.size(); idx++) {
			if (idx == 0)
				pw.write("{id:'" + idx + "',name:'" + tabs.get(idx).tableName + "(" + tabs.get(idx).tableDesc
						+ ")',noR:false}");
			else
				pw.write(",{id:'" + idx + "',name:'" + tabs.get(idx).tableName + "(" + tabs.get(idx).tableDesc
						+ ")',noR:false}");
		}
		pw.write("]"); 
		break;
	case "gendata":
		String txtSelDBTab = request.getParameter("txtSelDBTab");
		String txtPackage = request.getParameter("txtPackage");
		String txtFilter = request.getParameter("txtFilter");
		String txtModule = request.getParameter("txtModule");
		String txtSubModule = request.getParameter("txtSubModule");
		Boolean isOK = UI.genCode(txtFilter, txtPackage, txtModule, txtSubModule, txtSelDBTab);
		if (isOK) {			
			response.sendRedirect(UI.getOutZipPath());
		}
		break;
	default:
		out.println("other request");
	}
%>